package org.controller;

import org.entity.TSysUser;
import org.service.TSysUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 系统用户(TSysUser)表控制层
 *
 * @author makejava
 * @since 2021-10-19 09:36:14
 */
@Controller
@RequestMapping("tSysUser")
public class TSysUserController {
    /**
     * 服务对象
     */
    @Resource
    private TSysUserService tSysUserService;

    /**
     * 登录
     */
    @RequestMapping(value = "login")
    public String login(@RequestParam String account, @RequestParam String password, HttpSession session) {
        TSysUser tSysUser = new TSysUser();
        tSysUser.setAccount(account);
        tSysUser.setPassword(password);
        List<TSysUser> tSysUsers = tSysUserService.queryAll(tSysUser);
        if (tSysUsers.size() != 0) {
            session.setAttribute("tSysUsers", tSysUsers);
            return "main";
        } else {
            return "redirect:/index.jsp";
        }

    }

}